package com.xinhuajs.articlemg.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.xinhuajs.articlemg.dao.IUserDAO;
import com.xinhuajs.articlemg.pojo.User;
import com.xinhuajs.articlemg.service.IUserService;
@Service("userService")
public class UserServiceImpl implements IUserService{
	@Autowired
	private IUserDAO userDAO;
	
	@Override
	public String getUserByPageJSON(Map<String, Object> paramMap) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void getUsersByPage(Map<String, Object> paramMap) {
		userDAO.getUsersByPage(paramMap);
	}

	@Override
	public void saveUser(Map<String, Object> paramMap) {
		userDAO.saveUser(paramMap);
	}

	@Override
	public User getUserByUserid(String userid) {
		// TODO Auto-generated method stub
		return userDAO.getUserByUserid(userid);
	}
	
	
	@Override
	public List<User> getAll() {
		// TODO Auto-generated method stub
		return userDAO.getAll();
	}

	@Override
	public boolean addUser(User user) {
		boolean b;
		try {
			userDAO.addUser(user);
		} catch (Exception e) {
			b = false;
		}
		b = true;
		return b;
	}

	@Override
	public boolean checkAccount(User user) {
		User u = userDAO.getUserByAccount(user.getUsername());
		if (u != null) {
			return false;
		}
		return true;
	}

	@Override
	public User getUserByAccount(String username) {
		// TODO Auto-generated method stub
		return userDAO.getUserByAccount(username);
	}

	@Override
	public boolean upUser(User user) {
		boolean b;
		try {
			userDAO.upUser(user);
		} catch (Exception e) {
			b = false;
		}
		b = true;
		return b;
	}

	@Override
	public List<User> selUser(User user) {
		// TODO Auto-generated method stub
		return userDAO.selUser(user);
	}

	@Override
	public boolean delUser(String userid) {
		boolean b;
		try {
			userDAO.delUser(userid);
		} catch (Exception e) {
			b = false;
		}
		b = true;
		return b;
	}

	@Override
	public int selectCount() {
		// TODO Auto-generated method stub
		return userDAO.selectCount();
	}

	@Override
	public List<User> limit(int startIndex, int pageSize) {
		// TODO Auto-generated method stub
		return userDAO.limit(startIndex, pageSize);
	}

	@Override
	public List<User> selectByWhere(String where) {
		// TODO Auto-generated method stub
		return userDAO.selectByWhere(where);
	}

	@Override
	public int countByWhere(String where) {
		// TODO Auto-generated method stub
		return userDAO.countByWhere(where);
	}

	@Override
	public boolean upStatus(User user) {
		boolean b;
		try {
			userDAO.upStatus(user);
		} catch (Exception e) {
			b = false;
		}
		b = true;
		return b;
	}

	public void getUserByPage(Map<String, Object> paramMap) {
		// TODO Auto-generated method stub
		userDAO.getUsersByPage(paramMap);
	}

}
